package com.syas.dao.daos;

import com.syas.base.dao.daos.EntityDao;
import com.syas.dao.interfaces.IRateDao;
import com.syas.model.models.Rate;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository("RateDao")
public class RateDao extends EntityDao<Integer, Rate> implements IRateDao {
    @Override
    public List<Rate> getRateList(String hql) {
        return (List<Rate>)this.getSession().createQuery(hql).list();
    }
    @Override
    public List<Rate> getRateListSQL(String sql) {
        return (List<Rate>)this.getSession().createSQLQuery(sql).list();
    }
    @Override
    public Rate getRate(String sql) {
        List<Rate> rates = this.getSession().createSQLQuery(sql).list();
        return rates != null && rates.size() > 0 ? rates.get(0):new Rate();
    }
}
